import { _decorator, AudioSource, Component, director, Game, Node } from 'cc';
import { GameState } from './GameState';
const { ccclass, property } = _decorator;

@ccclass('baseScene')
export class baseScene extends Component {
    @property(Node)
    soundBtn: Node = null;
    audioSource: AudioSource = null;
    protected onLoad(): void {
        this.audioSource = this.getComponent(AudioSource);
    }
    stopSound() {
        this.audioSource.stop();
    }
    playSound() {
        if(GameState.soundOn){
            this.soundBtn.getChildByName('On').active = true;
            this.soundBtn.getChildByName('Off').active = false;
            this.audioSource.play();
        }else{
            this.soundBtn.getChildByName('On').active = false;
            this.soundBtn.getChildByName('Off').active = true;
            this.audioSource.stop();
        }
    }
}


